package com.wenwei.paper.activity;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;

import com.jaeger.library.StatusBarUtil;
import com.orhanobut.logger.Logger;
import com.wenwei.paper.R;
import com.wenwei.paper.base.AtyContainer;
import com.wenwei.paper.base.BaseActivity;
import com.wenwei.paper.utils.UserStringUtils;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.jpush.android.api.JPushInterface;

/**
 * Created by Administrator on 2017/7/13.
 */
public class HostActivity extends BaseActivity {
    @Bind(R.id.user_phone)
    TextView userPhone;

    @Override
    public int setLayoutResourceId() {
        return R.layout.activity_host;
    }

    @Override
    protected void initView() {
        super.initView();
        StatusBarUtil.setTranslucentForImageViewInFragment(this, 30, null);
        Logger.d(JPushInterface.getRegistrationID(mContext));

        userPhone.setText(UserStringUtils.getUserName(mContext));
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.host_set, R.id.host_message_tv, R.id.host_check_tv, R.id.host_bu_chong_tv, R.id.host_menu_tv, R.id.host_box_list_tv})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.host_set:
                goActivity(mContext, SettingActivity.class);
                break;
            case R.id.host_message_tv:
                //ok
                goActivity(mContext, MessageNotifyActivity.class);
                break;
            case R.id.host_check_tv:
                Bundle b1 = new Bundle();
                b1.putInt("type", 1);
                goActivity(mContext, QRcodeActivity.class, b1);
                break;
            case R.id.host_bu_chong_tv:
                //ok
                Bundle b2 = new Bundle();
                b2.putInt("type", 2);
                goActivity(mContext, QRcodeActivity.class, b2);
//                goActivity(mContext,ReplenishmentActivity.class);
                break;
            case R.id.host_menu_tv:
                //ok
                goActivity(mContext, UserMenuActivity.class);
                break;
            case R.id.host_box_list_tv:
                goActivity(mContext, BoxListActivity.class);
                break;
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK)) {
            AtyContainer.activityStack.clear();
            finish();
            return false;
        }else {
            return super.onKeyDown(keyCode, event);
        }

    }
}
